<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    输入年份:
    <input id="year" type="text" /><br />
    <input type="button" value="判断是平年还是闰年" onclick="fn()" /><br />
    <input id="result" type="text" />
    <!-- <script>
        function  fn(){
            var year=document.getElementById("year").value;
            var result="";
            if((year%4==0&&year%100!==0)||(year%400==0)){
                result="是闰年";
            }
            else{
                result="是平年";
            }
            document.getElementById("result").value=result;
        }
    </script> -->
    <script>
        function isRunYear(year) {
            result.value = year % 4 == 0 && year % 100 !== 0 || year % 400 == 0?"是闰年":"是平年"
            // console.log(result.value);
        }
        function fn(){
            isRunYear()
        }
    </script>
</body>

</html>